﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Collections.ObjectModel;

namespace Rance
{
    /// <summary>
    /// Win_Role.xaml 的交互逻辑
    /// </summary>
    public partial class Win_Role : Window
    {
        public Role Role { get; set; }

        public Win_Role(Role role)
        {
            Role = role;
            this.DataContext = role;
            InitializeComponent();

            List<string> 兵种List = new List<string>() { "剑士", "步卒", "骑兵", "弓兵", "侠客", "火枪", "战车", "炮兵", "巫师", "军乐队", "策士", "军师" };
            cmb兵种.ItemsSource = 兵种List;

            List<UI装备> 装备List = new List<UI装备>()
            {
                new UI装备("",""),
                new UI装备("吴钩","攻+1"),
                new UI装备("小圆盾","防+1"),
                new UI装备("六韬","智+1"),
                new UI装备("追风","速+1"),
                new UI装备("冥山弓","物伤+20"),
                new UI装备("护心镜","物理减伤+30"),
                new UI装备("令旗","兵力数+80"),
                new UI装备("纯钧","攻+2"),
                new UI装备("胜邪","攻+1,防+1"),
                new UI装备("月华弓","物伤+50"),
                new UI装备("落日弓","物伤+80"),
                new UI装备("鱼肠","攻+1,速+1"),
                new UI装备("燕尾方盾","防+2"),
                new UI装备("青铜护甲","物理减伤+60"),
                new UI装备("楚骓","速+2"),
                new UI装备("赤骥","速+1,防+1"),
                new UI装备("孙子兵法","智+2"),
                new UI装备("鹰符","兵力数+150"),
                new UI装备("虎符","兵力数+200"),
                new UI装备("龙符","兵力数+300"),
                new UI装备("晨凫","速+2,防+1"),
                new UI装备("飞翩","速+2,攻+1"),
                new UI装备("华骝","速+2,智+1"),
                new UI装备("干将","攻+2,防+1"),
                new UI装备("莫邪","攻+2,速+1"),
                new UI装备("湛卢","攻+1,防+1,速+1"),
                new UI装备("诸侯信印","每回合自动恢复30兵力"),
                new UI装备("天子令旗","每回合自动恢复50兵力"),
            };

            cmb装备.ItemsSource = 装备List;

            UI装备 装备 = (from e in 装备List
                       where e.Name == role.装备
                       select e).SingleOrDefault();
            if (装备 != null)
                cmb装备.SelectedItem = 装备;
        }

        private void cmb兵种_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            List<string> aiList = new List<string>();
            switch (cmb兵种.SelectedItem.ToString())
            {
                case "剑士":
                    cmb基础攻击技能.ItemsSource = new List<string>() { "斩击1", "斩击2", "斩击3" };
                    cmb技能1.ItemsSource = new List<string>() { "", "追风剑1", "追风剑2", "怒剑决1", "怒剑决2", "佯攻1", "佯攻2", "新月斩" };
                    cmb技能2.ItemsSource = new List<string>() { "", "剑魂1", "剑魂2" };
                    cmb被动技能.ItemsSource = new List<string>() { "", "攻击强化1", "攻击强化2", "防御强化1", "防御强化2", "速度强化1", "速度强化2", "智力强化1", "智力强化2", "剑气护体" };
                    aiList.Add("剑士AI");
                    aiList.Add("剑士AI_击杀");
                    aiList.Add("剑士AI_压血");
                    break;
                case "步卒":
                    cmb基础攻击技能.ItemsSource = new List<string>() { "盾击1", "盾击2", "盾击3" };
                    cmb技能1.ItemsSource = new List<string>() { "", "枪袭1", "枪袭2", "复仇之刃", "后发制人" };
                    cmb技能2.ItemsSource = new List<string>() { "", "守护队友1", "守护队友2", "守护全体队友" };
                    cmb被动技能.ItemsSource = new List<string>() { "", "攻击强化1", "攻击强化2", "防御强化1", "防御强化2", "速度强化1", "速度强化2", "智力强化1", "智力强化2", "初期强力防御", "初期全体防御", "反击强化1", "反击强化2", "浴血奋战" };
                    txt特殊技能.Text = "初期防御";
                    aiList.Add("步卒AI");
                    aiList.Add("步卒AI_伤害");
                    break;
                case "骑兵":
                    cmb基础攻击技能.ItemsSource = new List<string>() { "冲锋1", "冲锋2", "冲锋3" };
                    cmb技能1.ItemsSource = new List<string>() { "", "疾风扫荡1", "疾风扫荡2", "疾风扫荡3", "来去如风1", "来去如风2", "来去如风3" };
                    cmb技能2.ItemsSource = new List<string>() { "", "百骑劫营" };
                    cmb被动技能.ItemsSource = new List<string>() { "", "攻击强化1", "攻击强化2", "防御强化1", "防御强化2", "速度强化1", "速度强化2", "智力强化1", "智力强化2" };
                    aiList.Add("骑兵AI");
                    break;
                case "弓兵":
                    cmb基础攻击技能.ItemsSource = new List<string>() { "弓箭射击1", "弓箭射击2", "弓箭射击3", "阻击盾兵", "阻击剑士" };
                    cmb技能1.ItemsSource = new List<string>() { "", "箭雨1", "箭雨2", "箭雨3", "弩炮1", "弩炮2", "弩炮3" };
                    cmb技能2.ItemsSource = new List<string>() { "" };
                    cmb被动技能.ItemsSource = new List<string>() { "", "攻击强化1", "攻击强化2", "防御强化1", "防御强化2", "速度强化1", "速度强化2", "智力强化1", "智力强化2", "阻击剑士", "阻击步卒" };
                    aiList.Add("弓兵AI");
                    break;
                case "侠客":
                    cmb基础攻击技能.ItemsSource = new List<string>() { "袖中剑1", "袖中剑2", "袖中剑3" };
                    cmb技能1.ItemsSource = new List<string>() { "", "恶即斩1", "恶即斩2", "恶即斩3", "迅步追魂1", "迅步追魂2", "迅步追魂3", "舍生取义1", "舍生取义2", "舍生取义3" };
                    cmb技能2.ItemsSource = new List<string>() { "" };
                    cmb被动技能.ItemsSource = new List<string>() { "", "攻击强化1", "攻击强化2", "防御强化1", "防御强化2", "速度强化1", "速度强化2", "智力强化1", "智力强化2" };
                    aiList.Add("侠客AI");
                    aiList.Add("侠客AI_输出");
                    aiList.Add("侠客AI_暗杀");
                    aiList.Add("侠客AI_守护");
                    break;
                case "火枪":
                    cmb基础攻击技能.ItemsSource = new List<string>() { "火枪射击1", "火枪射击2", "火枪射击3" };
                    cmb技能1.ItemsSource = new List<string>() { "", "瞄准1", "瞄准2", "瞄准3", "恫吓1", "恫吓2", "恫吓3" };
                    cmb技能2.ItemsSource = new List<string>() { "" };
                    cmb被动技能.ItemsSource = new List<string>() { "", "攻击强化1", "攻击强化2", "防御强化1", "防御强化2", "速度强化1", "速度强化2", "智力强化1", "智力强化2" };
                    aiList.Add("火枪AI");
                    break;
                case "战车":
                    cmb基础攻击技能.ItemsSource = new List<string>() { "冲刺攻击1", "冲刺攻击2", "冲刺攻击3" };
                    cmb技能1.ItemsSource = new List<string>() { "千乘旋风1", "千乘旋风2", "穿梭战场1", "穿梭战场2" };
                    cmb技能2.ItemsSource = new List<string>() { "" };
                    cmb被动技能.ItemsSource = new List<string>() { "", "攻击强化1", "攻击强化2", "防御强化1", "防御强化2", "速度强化1", "速度强化2", "智力强化1", "智力强化2", "铁甲战车1", "铁甲战车2", "铁甲战车3", "王者旌旗1", "王者旌旗2", "王者旌旗3", "紧急救援" };
                    aiList.Add("战车AI");
                    aiList.Add("战车AI_击杀");
                    aiList.Add("战车AI_压血");
                    break;
                case "炮兵":
                    cmb基础攻击技能.ItemsSource = new List<string>() { "炮击1", "炮击2", "炮击3" };
                    cmb技能1.ItemsSource = new List<string>() { "火力压制1", "火力压制2", "火力压制3", "震天雷1", "震天雷2", "震天雷3" };
                    cmb技能2.ItemsSource = new List<string>() { "" };
                    cmb被动技能.ItemsSource = new List<string>() { "", "攻击强化1", "攻击强化2", "防御强化1", "防御强化2", "速度强化1", "速度强化2", "智力强化1", "智力强化2" };
                    aiList.Add("炮兵AI");
                    break;
                case "巫师":
                    cmb基础攻击技能.ItemsSource = new List<string>() { "毒盅术1", "毒盅术2", "毒盅术3" };
                    cmb技能1.ItemsSource = new List<string>() { "", "招风术1", "招风术2", "招风术3", "豪雨术1", "豪雨术2", "豪雨术3" };
                    cmb技能2.ItemsSource = new List<string>() { "", "护身术", "全体护身术" };
                    cmb被动技能.ItemsSource = new List<string>() { "", "攻击强化1", "攻击强化2", "防御强化1", "防御强化2", "速度强化1", "速度强化2", "智力强化1", "智力强化2" };
                    aiList.Add("巫师AI");
                    aiList.Add("巫师AI_守护");
                    break;
                case "军乐队":
                    cmb基础攻击技能.ItemsSource = new List<string>() { "弓箭射击1", "弓箭射击2", "弓箭射击3" };
                    cmb技能1.ItemsSource = new List<string>() { "征兵令1", "征兵令2", "高级征兵令" };
                    cmb技能2.ItemsSource = new List<string>() { "", "义勇军1", "义勇军2", "振奋号角1", "振奋号角2", "医仙降临" };
                    cmb被动技能.ItemsSource = new List<string>() { "", "攻击强化1", "攻击强化2", "防御强化1", "防御强化2", "速度强化1", "速度强化2", "智力强化1", "智力强化2" };
                    aiList.Add("军乐队AI");
                    aiList.Add("军乐队AI_治疗");
                    aiList.Add("军乐队AI_其他");
                    break;
                case "策士":
                    cmb基础攻击技能.ItemsSource = new List<string>() { "弓箭射击1", "弓箭射击2", "弓箭射击3" };
                    cmb技能1.ItemsSource = new List<string>() { "运筹帷幄1", "运筹帷幄2", "运筹帷幄3", "锦囊妙计1", "锦囊妙计2" };
                    cmb技能2.ItemsSource = new List<string>() { "伪报1", "伪报2", "先发制人", "空城计", "神机妙算" };
                    cmb被动技能.ItemsSource = new List<string>() { "", "攻击强化1", "攻击强化2", "防御强化1", "防御强化2", "速度强化1", "速度强化2", "智力强化1", "智力强化2", "先发制人", "神机妙算" };
                    aiList.Add("策士AI");
                    aiList.Add("策士AI_拖延");
                    aiList.Add("策士AI_行动点");
                    aiList.Add("策士AI_战场修正");
                    aiList.Add("策士AI_战果");
                    break;
                case "军师":
                    cmb基础攻击技能.ItemsSource = new List<string>() { "弓箭射击1", "弓箭射击2", "弓箭射击3" };
                    cmb技能1.ItemsSource = new List<string>() { "水淹七军1", "水淹七军2", "伏兵之计1", "伏兵之计2", "鼓舞1", "鼓舞2", "全体鼓舞1", "全体鼓舞2", "全体看破1", "全体看破2", "谣言1", "谣言2" };
                    cmb技能2.ItemsSource = new List<string>() { "水淹七军1", "水淹七军2", "伏兵之计1", "伏兵之计2", "鼓舞1", "鼓舞2", "全体鼓舞1", "全体鼓舞2", "全体看破1", "全体看破2", "谣言1", "谣言2" };
                    cmb被动技能.ItemsSource = new List<string>() { "", "攻击强化1", "攻击强化2", "防御强化1", "防御强化2", "速度强化1", "速度强化2", "智力强化1", "智力强化2", "攻击之阵1", "攻击之阵2", "防御之阵1", "防御之阵2", "速度之阵1", "速度之阵2", "谋略之阵1", "谋略之阵2" , "王者之阵" };
                    aiList.Add("军师AI");
                    aiList.Add("军师AI_攻击");
                    aiList.Add("军师AI_强化");
                    aiList.Add("军师AI_削弱");
                    aiList.Add("军师AI_加速");
                    break;
            }

            cmbAI.ItemsSource = aiList;
            if (aiList.Count() > 0 && cmbAI.SelectedItem == null)
                cmbAI.SelectedItem = aiList[0];
        }

        private void btnCofirm_Click(object sender, RoutedEventArgs e)
        {
            if (Role.兵种 == null)
            {
                MessageBox.Show("请选择兵种");
                return;
            }

            if (Role.基础攻击技能 == null)
            {
                MessageBox.Show("请选择基础攻击技能");
                return;
            }

            if (Role.技能1 == null)
                Role.技能1 = "";
            if (Role.技能2 == null)
                Role.技能2 = "";
            if (Role.被动技能 == null)
                Role.被动技能 = "";
            Role.特殊技能 = txt特殊技能.Text;
            if(cmb装备.SelectedItem == null)
                Role.装备 = string.Empty;
            else
            {
                UI装备 装备 = (UI装备)cmb装备.SelectedItem;
                Role.装备 = 装备.Name;
            }


            this.DialogResult = true;
        }

        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }
    }
}
